package ae.pcfc.cldos.online.common.etksdb.dao.provider;

import java.util.List;

import org.hibernate.criterion.DetachedCriteria;
import org.hibernate.criterion.Restrictions;

import ae.pcfc.cldos.online.common.dao.GenericDAO;
import ae.pcfc.cldos.online.common.etksdb.dao.ClientDAO;
import ae.pcfc.cldos.online.common.etksdb.domain.Client;

/**
 * 
 * @author arosa
 *
 */
public class ClientDAOImpl extends GenericDAO implements ClientDAO {

	public Client getClientById(Long clientId){
		return (Client)findById(Client.class, clientId);
	}
	
	public Long getClientIdByTrakheesId(String trakheesId){
		return (Long)getProperty(Client.class, Restrictions.eq(Client.TRAKHEES_ID, trakheesId), Client.ID);
	}
	
	/**
	 * @return
	 */
	@SuppressWarnings("unchecked")
	public List<Client> getAllActiveClients(){
		DetachedCriteria criteria = DetachedCriteria.forClass(Client.class);
		criteria.add(Restrictions.eq(Client.CLIENT_STATUS, "A"));
		return (List<Client>)getListByCriteria(criteria);
	}
}
